/*
 Arcana by HTML5 UP
 html5up.net | @n33co
 Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
 */

(function ($) {
    $(function () {
        var $window = $(window), $body = $('body'), menu = $('#nav'), pos = menu.offset();

        // Disable animations/transitions until the page has loaded.
        $body.addClass('is-loading');

        $window.on('load', function () {
            $body.removeClass('is-loading');
        });

        $(window).scroll(function () {
            if ($(this).scrollTop() > pos.top + menu.height() && menu.hasClass('nav-default')) {
                menu.fadeOut('fast', function () {
                    $(this).removeClass('nav-default').addClass('nav-fixed').fadeIn();
                });
            } else if ($(this).scrollTop() <= pos.top && menu.hasClass('nav-fixed')) {
                menu.fadeOut('fast', function () {
                    $(this).removeClass('nav-fixed').addClass('nav-default').fadeIn();
                });
            }
        });

        // Dropdowns.
        $('#nav > ul').dropotron({
            offsetY: -15,
            hoverDelay: 0,
            alignment: 'center'
        });
    });
})(jQuery);